package com.ztf0337.mycurriculumdesign.Utils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Locale;
public class AccountUtils {

    public static String settleAccountToString(Double perHoursPrice, Double sumTime) {
        if (perHoursPrice == null || sumTime == null) return "￥ 0.00";
        double totalPrice = perHoursPrice * sumTime;
        return String.format(Locale.CHINA, "￥ %.2f", totalPrice);
    }

    public static Double settleAccountToDouble(Double perHoursPrice, Double sumTime) {
        if (perHoursPrice == null || sumTime == null) return 0.0;

        BigDecimal price = BigDecimal.valueOf(perHoursPrice);
        BigDecimal time = BigDecimal.valueOf(sumTime);
        BigDecimal total = price.multiply(time).setScale(2, RoundingMode.HALF_UP); // 保留两位，四舍五入

        return total.doubleValue();
    }



}
